import 'package:inmotion_pro/pages/models/user_model.dart';
import 'package:lx_widgets_library/lx_widgets_library.dart';
import 'package:safemap/safemap.dart';

// 用户信息响应模型
class UserInfoResponseModel extends BaseData {
  // 令牌
  String token;

  // x_auth
  String xAuth;

  // 用户信息
  UserModel user;

  UserInfoResponseModel({
    this.token = '',
    this.xAuth = '',
    required this.user,
  });

  factory UserInfoResponseModel.fromJson(Map<String, dynamic> json) {
    SafeMap safeMap = SafeMap(json);
    final token = safeMap['token'].string ?? '';
    final xAuth = safeMap['x_auth'].string ?? '';
    UserModel user = safeMap['user'].map != null
        ? UserModel.fromMap(safeMap['user'].map as Map<String, dynamic>)
        : UserModel.fromMap({});
    return UserInfoResponseModel(
      token: safeMap['token'].string ?? '',
      xAuth: safeMap['x_auth'].string ?? '',
      user: user
        ..token = token
        ..xAuth = xAuth,
    );
  }
}
